<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>地图API地点搜</title>
	<meta name="description" content="百度地图" /> 
	<meta name="keywords" content="百度地图" /> 
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=1.2&ak=o5kQ9hyNX080TUhUGVW3GTyohTwbQyIA"></script>
    <!--<script type="text/javascript" src="http://webapi.amap.com/maps?v=1.4.0&key=f2e4ebde8313e416f6c2f89090c98e20"></script>-->
    <!--<script type="text/javascript" src="http://ditu.google.com/maps?file=api&hl=zh-CN&v=2&key=f2e4ebde8313e416f6c2f89090c98e20"></script>-->
</head>
<body>
<center>
<h5>输入地点然后点击“地图上找”搜索，点击地图地点获取相应经纬度</h5>
<form action="" method="get">
  <label >地  点：</label>
  <input id="where" name="where" type="text"  >
  <input type="button" value="地图上找" onClick="sear(document.getElementById('where').value);" />
  <br /><br />
    经纬度：
    <input id="lonlat" name="lonlat"  class="lonlat icon"   type="text"   > <br /> <br />
  <div style="width:520px;height:340px;border:1px solid gray" id="container"></div>

</form>
</center>
<script type="text/javascript">
var map = new BMap.Map("container");//在指定的容器内创建地图实例
map.setDefaultCursor("crosshair");//设置地图默认的鼠标指针样式
map.enableScrollWheelZoom();//启用滚轮放大缩小，默认禁用。
map.centerAndZoom(new BMap.Point(108.953098,34.2778), 11);
map.addControl(new BMap.NavigationControl()); 
map.addEventListener("click", function(e){ //地图单击事件
    document.getElementById("lonlat").value =  e.point.lng + "," +e.point.lat;
//    window.opener.document.getElementById("latitude").value= e.point.lat ;
//    window.opener.document.getElementById("longitude").value=e.point.lng ;

    // 给主页面的inout 赋值
    window.parent.document.getElementById("latitude").value=e.point.lng;
    window.parent.document.getElementById("longitude").value=e.point.lat;
});
function iploac(result){ //根据IP设置地图中心
    var areaName = result.name;
    map.setCenter(areaName);
}

function sear(result){ //地图搜索
	var local = new BMap.LocalSearch(map, {
  		renderOptions:{map: map}
	});
	local.search(result);
}

</script>
</body>
</html>